using Eleven_Threety_RK.BLL;
using Eleven_Threety_RK.DAL;
using Microsoft.EntityFrameworkCore;
using NLog.Web;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.

builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

builder.Services.AddControllers().AddJsonOptions(H=>H.JsonSerializerOptions.PropertyNamingPolicy=null);
builder.Services.AddDbContext<Mycontext>(X=>X.UseSqlServer(builder.Configuration.GetConnectionString("db")));

builder.Services.AddScoped<UserDal>();
builder.Services.AddScoped<UserBll>();

builder.Host.UseNLog();
var app = builder.Build();
app.UseCors(F=>{ F.AllowAnyMethod().AllowAnyHeader().AllowAnyOrigin(); });

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

app.UseHttpsRedirection();

app.UseAuthorization();

app.MapControllers();

app.Run();
